package com.ht.log;

import java.util.Date;
import java.util.List;
import java.sql.Connection;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2009-6-6
 */
public interface CommandPersistLayer extends DBTypes {

    public static final String DEFAULT_CMD_TABLE_NAME = "SH_COMMAND";

    /**
     * @param num number of items user wanna to get
     * @return query result
     */
    public List<DeviceCommand> getLastCommands(int num);

    /**
     * @param fromTime time of command
     * @return commands whose created time is larger than parameter
     */
    public List<DeviceCommand> getLastCommands(Date fromTime);

    public DeviceCommand getCommand(String deviceId,Date fromTime);

    public List<DeviceCommand> query(CommandQueryCondition condition);

    public List<DeviceCommand> query(CommandQueryCondition condition, int pageNo, int pageSize);

    public int query(CommandQueryCondition cqc, List<DeviceCommand> list, int pageNo, int pageSize);

    public int getTotalPageCounts(String tableName, CommandQueryCondition con);

    public List<DeviceCommand> getQueryListByPageNo(String tableName, CommandQueryCondition con, int startRow, int endRow);

    public List<DeviceCommand> query(String tableName, CommandQueryCondition condition);

    public boolean addCommand(DeviceCommand command);

    public boolean updateCommand(DeviceCommand command);

    public boolean deleteCommand(DeviceCommand command);

    public void close();

    public Connection createConnection();

    public void closeConnection(Connection connection);

    int getTotalPageCounts(String beforeDayTable, CommandQueryCondition con, Connection connection);

    List<DeviceCommand> getQueryListByPageNo(String talbe, CommandQueryCondition con, int startRow, int endRow, Connection connection);
}
